<template>
  <div class="order-div">
    <div class="order-wrap">
      <div class="item" v-for="(item, index) in list" :key="index">
        <span class="time">{{formatDate(new Date(item.create_time).getTime())}}</span>
        <span class="type" style="background:#61affe" v-if="item.type=='ADMIRE'">تارتۇقلاش</span>
        <span class="type" style="background:#49cc90" v-if="item.type=='VIP'">ئالىي ئەزا</span>
        <span class="type" style="background:#328ee4" v-if="item.type=='MOVIE'">كىنو</span>
        <span class="money" v-if="item.money">{{(item.money/100).toFixed(2)}} يۈەن</span>
      </div>
    </div>
    <div class="empty" v-if="emptyList">
            <span>تۈگەپتۇ</span>
    </div>
  </div>
</template>
<script>
import { formatDate ,shareFrend, shareMoments } from "@/utils";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      list: [],
      pageNum: 1,
      pageSize: 20,
      emptyList:false
    };
  },
  methods: {
    formatDate,
    async getOrder() {
      try {
        let openId = JSON.parse(window.localStorage.getItem('userInfo')).openid
        let res = await this.$http.get("/getOrderList",{ params:{ openId }});
        this.list = JSON.parse(this.$decrypt(res));
        if(!res.length){
            this.emptyList = true;
        }
      } catch (error) {}
    }
  },
  mounted() {
    shareFrend(this);
    shareMoments(this);
    this.getOrder();
  }
};
</script>

<style lang="scss" scoped>
.order-div {
  .order-wrap {
    border: 1px solid transparent;
    .item {
      width: 98%;
      height: 93px;
      box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.15);
      border-radius: 22px;
      margin: 0 auto;
      display: flex;
      justify-content: space-around;
      align-items: center;
      margin-bottom: 10px;
      font-size: 28px;

      &:first-of-type {
        margin-top: 10px;
      }
      .time {
        color: #123;
      }
      .type {
        height: 60%;
        border-radius: 36px;
        width: 150px;
        background: #f8f8f8;
        display: flex;
        justify-content: center;
        align-items: center;
        color: #fff;
      }
      .money {
        direction: rtl;
      }
    }
  }
}
.empty {
        min-height: 100vh;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 35px;
    }
</style>